<?php

defined('MYLITS') ? '' : exit('No direct script access allowed');

/**
 * @version     1.0.0
 * @package     mylits engine
 * @license     GNU General Public License version 3
 * @author      Arfan Fudyartanto D N <arfan@mylits.com> - http://engine.mylits.com
 */
class languageModel extends Mylits_Model {

    public function __construct() {
        parent::__construct();
        $this->setConnectionNumber(0);
        $this->setSqlFile('language');
    }

    /**
     * Method to get translation value from translation key
     * 
     * @param string $langTextCode -> text code will be translated
     * @param string $langCode -> country code (standart ISO 639-1)
     * @return string -> translation value
     */
    public function getText($langTextCode, $langCode) {
        $query = $this->openQuery('get_translation', array($langTextCode, $langCode));
        $result = $this->runQuery($query);
        if (empty($result)) {
            return "[$langTextCode]";
        } else {
            return $result[0]['translation'];
        }
    }

}

?>
